package com.xinxin.leetcode.problem383;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ShiXinXin
 * @date 2019-12-15 3:29
 */
public class Solution {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] arr = new int[26];
        for (char c : ransomNote.toCharArray()) {
            ++arr[c - 97];
        }
        for (char c : magazine.toCharArray()) {
            --arr[c - 97];
        }
        for (int i = 0; i < 26; i++) {
            if (arr[i] > 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new Solution().canConstruct("aa", "aba"));
    }
}
